<extend name="Layout/ins_popup" />
<block name="content">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-frame">
		<div class="popup-header">
			<div class="pull-left">
				<h1>添加后台任务</h1>
			</div>
			<div class="pull-right">
				<a id="btn_save" class="btn" >确定</a>
				<a id="btn_close" class="btn btn-cancel">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<form id="form_data" name="form_data" method="post" >
						<input type="hidden" name="id" id="id" >
						<input type="hidden" name="opmode" id="opmode" value="add">
						<div class="layui-form-item">
							<label class="layui-form-label" for="name">名称*：</label>
							<div class="layui-input-block">
								<input class="layui-input" type="text" id="name" name="name" check="required" info="请输入名称">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" for="command">命令*：</label>
							<div class="layui-input-block">
								<input class="layui-input" type="text" id="command" name="command" check="required" info="请输入命令">
							</div>
						</div>
						<div class="layui-sub-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">类型*：</label>
								<label class="col-4">每</label>
								<div class="layui-input-inline col-5">
									<input type="text" class="layui-input"  name="interval" id="interval">
								</div>
								<div class="layui-input-inline col-9">
									<select class="layui-input" name="type" id="type" onchange="test()">
										<option>请选择</option>
										<option value="D">天</option>
										<option value="S">秒</option>
									</select>
								</div>
								<div class="layui-input-inline col-9" >
									<input class="layui-input hidden" style="display: inline" type="time" id="time" name="time">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" for="start_date">开始日期*：</label>
							<div class="layui-input-block">
								<input class="layui-input input-date" type="text" id="start_date" name="start_date" check="required" info="请选择开始日期">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" for="end_date">结束日期*：</label>
							<div class="layui-input-block">
								<input class="layui-input input-date" type="text" id="end_date" name="end_date" check="required" info="">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" for="sort">排序：</label>
							<div class="layui-input-block">
								<input class="layui-input col-6" type="text" id="sort" name="sort" >
							</div>
						</div>
					</form>
				</div>
			</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			//保存后关闭
			$('#btn_save').on('click', function() {
				send_form('form_data', '{:U("save_timer")}', '', function(ret) {
					if (ret.status == 1) {
						layer.msg(ret.info, {
							time : 1200
						}, function() {
							parent.location.reload(true);
							parent.layer.close(index);
						});
					} else {
						parent.layer.msg(ret.info);
						return false;
					}
				});
			});

			//关闭iframe
			$('#btn_close').click(function() {
				parent.layer.close(index);
			});

			$("#type").on('change', function() {

				if ($("#type").val() == 'D') {
					$("#time").removeClass('hidden');
				} else {
					$("#time").addClass('hidden');
				}
			});
		});

	</script>
</block>